package com.controller;
import com.domain.Blog;
import com.service.Service1;
import com.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/user")
public class Controller1 {
      /*controller层调用业务层*/
    @Autowired
    @Qualifier("serviceImpl")
    private Service1 service1;
    @RequestMapping("/find")
     public String findAllTest(Model model, HttpServletRequest request){
         List<Blog> blogList = service1.fingAll();
        for (Blog blog : blogList) {
            System.out.println(blog);
        }
        //request.setAttribute("blogList",blogList);
       // model.addObject("blogList",blogList);
        model.addAttribute("blogList",blogList) ;
         return "allbooks";
     }
}
